home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / systems / mac / textures / graphics / rotate.tex < prev    next >
Text File  |  1994-07-08  |  2KB  |  51 lines

  1. %
  2. %   These macros allow you to rotate or flip a \TeX\ box.  Very useful for
  3. %   sideways tables or upsidedown answers.
  4. %
  5. %   To use, create a box containing the information you want to rotate.
  6. %   (An hbox or vbox will do.)  Now call \rotr\boxnum to rotate the
  7. %   material and create a new box with the appropriate (flipped) dimensions.
  8. %   \rotr rotates right, \rotl rotates left, \rotu turns upside down, and
  9. %   \rotf flips.  These boxes may contain other rotated boxes.
  10. %
  11. %   Originally written by Tomas Rokicki, and distributed with dvips.
  12. %   Modified for Textures by Barry Smith, Blue Sky Research, 08Jul94
  13.  
  14. \catcode`\@=11
  15. \newdimen\rotdimen
  16. \newbox\rotbox
  17.  
  18. \def\rotstart#1{\special{postscript 0 0 transform}% get current point
  19.   \special{rawpostscript gsave itransform 2 copy translate
  20.    #1 neg exch neg exch translate}}% #1 can be any origin-fixing transformation
  21. \def\rotfinish{\special{rawpostscript currentfont grestore setfont}}% gets back in synch
  22. %
  23. %   First, the rotation right. The reference point of the rotated box
  24. %   is the lower right corner of the original box.
  25. %
  26. \def\rotr#1{\rotdimen=\ht#1\advance\rotdimen by\dp#1%
  27.    \hbox to\rotdimen{\hskip\ht#1\vbox to\wd#1{\rotstart{90 rotate}%
  28.    \box#1\vss}\hss}\rotfinish}
  29. %
  30. %   Next, the rotation left. The reference point of the rotated box
  31. %   is the upper left corner of the original box.
  32. %
  33. \def\rotl#1{\rotdimen=\ht#1\advance\rotdimen by\dp#1%
  34.    \hbox to\rotdimen{\vbox to\wd#1{\vskip\wd#1\rotstart{270 rotate}%
  35.    \box#1\vss}\hss}\rotfinish}%
  36. %
  37. %   Upside down is simple. The reference point of the rotated box
  38. %   is the upper right corner of the original box. (The box's height
  39. %   should be the current font's xheight, \fontdimen5\font,
  40. %   if you want that xheight to be at the baseline after rotation.)
  41. %
  42. \def\rotu#1{\rotdimen=\ht#1\advance\rotdimen by\dp#1%
  43.    \hbox to\wd#1{\hskip\wd#1\vbox to\rotdimen{\vskip\rotdimen
  44.    \rotstart{-1 dup scale}\box#1\vss}\hss}\rotfinish}%
  45. %
  46. %   And flipped end for end is pretty ysae too. We retain the baseline.
  47. %
  48. \def\rotf#1{\hbox to\wd#1{\hskip\wd#1\rotstart{-1 1 scale}%
  49.    \box#1\hss}\rotfinish}%
  50.  
  51.